function check(name,valuestr){
		values=valuestr.split(',');
		if(values!=null&&values.length>0){
			eles = document.getElementsByName(name);
			for(i=0; i< eles.length; i++){
				for(j=0; j< values.length; j++){
					if(eles[i].value==values[j])
						eles[i].checked=true;
					else
						eles[i].checked=false;
				}
			}
		}
}
function _obj(id){
	return document.getElementById(id);
}
function checkselect(id,value){
	ops = document.getElementById(id).options;
	if(ops!=null&&ops.length>0){
		for(i=0;i<ops.length;i++){
			if(ops[i].value==value){
				ops[i].selected=true;
			}
		}
	}
}

function getRadioValue(name){
	radioEles = document.getElementsByName(name);
	for(i=0; i<radioEles.length; i++){
		if(radioEles[i].checked)
			return radioEles[i].value;
	}
	return null;
}


function page(pageno) {
	frm = event.srcElement;
	do{
		frm=frm.parentElement;
	}while(frm.tagName!="FORM");
	ops=frm.getAttribute("d_op");//.value;
 	if(ops) frm.op.value=ops;
    frm.pageno.value = pageno;
    frm.submit();
  } 
  
function selectAll(ev){
 	ev= ev || window.event;
	form = ev.target || ev.srcElement;
	do{
		form=form.parentElement;
	}while(form.tagName!="FORM");
	
     if(form.box==undefined)
         return;
     if(form.box.length==undefined){
         form.box.checked = form.AllBox.checked;
         return;
     }
     for(i=0;i<form.box.length;i++){
         form.box[i].checked = form.AllBox.checked;
     }
 }
  function checkByName(name,bool){
    cbeles = document.getElementsByName(name);
	  for( i=0; i < cbeles.length; i++)
		  cbeles[i].checked=bool;
  }
 
 /**
 	ckbvalue:  value1,value2,
 */
 function checkvalue(ckbname,ckbvalue) {
	var aTmp =ckbvalue.split(",");
	ck_eles = document.getElementsByName(ckbname);
	for( i = 0; i < aTmp.length; i++ ) {
		for( j = 0;j < ck_eles.length; j++ ) {
			if( aTmp[i] == ck_eles[j].value )
			  ck_eles[j].checked = true;
		}
	}
 }
 
 function sort(proname,formId,pre){
 	frm = _obj(formId);
 	if(proname==frm.property.value){
 		if(frm.order.value=='DESC')
 			frm.order.value='ASC';
 		else
 			frm.order.value='DESC';
 	}else{
 		frm.order.value='DESC';
 	}
 	ops=frm.getAttribute("d_op");//.value;
 	if(ops) frm.op.value=ops;
 	frm.property.value=proname;
 	frm.submit();
 }
 
function loadSortPic(){
	property =document.getElementsByName("property");
	if(property&&property.length>0){
		sortEle=_obj('sort_'+property[0].value);
		if(sortEle){
			order =document.getElementsByName("order");
			if(order[0].value=='DESC'){
				img = createImg(true);
			}else
				img=createImg();
			sortEle.parentNode.appendChild(img);
		}
	}
}

function createImg(flag){
	var newImage = document.createElement("img");
		if(flag)newImage.src=base+"/template/images/sort_desc.gif";
	else
		newImage.src=base+"/template/images/sort_asc.gif";
	return newImage;
}

window.attachEvent("onload",loadSortPic); 

